import { Disposable, ICommandService, Inject } from '@univerjs/core';
import { ComponentManager, IMenuManagerService, RibbonStartGroup } from '@univerjs/ui';
import { PrintSingle } from '@univerjs/icons';

import { JnpfSheetsPrintOperation } from '../commands/operations/sheet-print.operation';
import { JnpfSheetsPrintMenuFactory } from '../controllers/menus/sheet-print.menu';

export class JnpfSheetsPrintController extends Disposable {
  constructor(
    // @Inject(Injector) private readonly _injector: Injector,
    @ICommandService private readonly _commandService: ICommandService,
    @IMenuManagerService private readonly _menuManagerService: IMenuManagerService,
    @Inject(ComponentManager) private readonly _componentManager: ComponentManager,
  ) {
    super();

    this._initCommands();
    this._registerComponents();
    // this._initMenus();
  }

  private _initCommands(): void {
    [JnpfSheetsPrintOperation].forEach(command => {
      this.disposeWithMe(this._commandService.registerCommand(command));
    });
  }

  private _registerComponents(): void {
    this.disposeWithMe(this._componentManager.register('PrintSingle', PrintSingle));
  }

  private _initMenus(): void {
    this._menuManagerService.mergeMenu({
      // 主菜单
      [RibbonStartGroup.OTHERS]: {
        [JnpfSheetsPrintOperation.id]: {
          order: 100,
          menuItemFactory: JnpfSheetsPrintMenuFactory,
        },
      },
      // 右键菜单
      // [ContextMenuPosition.MAIN_AREA]: {
      //   [ContextMenuGroup.OTHERS]: {
      //     [JnpfSheetsPrintOperation.id]: {
      //       order: 0,
      //       menuItemFactory: JnpfSheetsPrintMenuFactory,
      //     },
      //   },
      // },
    });
  }
}
